package cc.example;

import java.util.concurrent.Flow;
import java.util.concurrent.SubmissionPublisher;

/**
 * 中间操作
 */
public class MyProcessor2 extends SubmissionPublisher<String> implements Flow.Processor<String, String> {
    private Flow.Subscription subscription;
    @Override
    public void onSubscribe(Flow.Subscription subscription) {
        System.out.println("MyProcessor1 订阅绑定完成");
        this.subscription = subscription;
        subscription.request(1);
    }

    @Override
    public void onNext(String item) {
        System.out.println("MyProcessor1 拿到数据" + item);
        item = "<------> 2" + item;
        submit(item);
        subscription.request(1);
    }

    @Override
    public void onError(Throwable throwable) {

    }

    @Override
    public void onComplete() {

    }
}
